﻿using System;
using System.Windows;
using Microsoft.Win32;
using Sokoban.ViewModel;

namespace Sokoban
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();         
        }

        private void MainWindow_StartButton_Click(object sender, RoutedEventArgs e)
        {
            var path = LoadMAp();
            if (!string.IsNullOrEmpty(path))
            {
                GameWindow Game = new GameWindow(path);
                Game.ShowDialog();
            }
        }

        private string LoadMAp()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Multiselect = false;
            ofd.ShowDialog();

            if (!string.IsNullOrEmpty(ofd.SafeFileName))
            {
                return ofd.FileName;
            }
            else
            {
                return string.Empty;
            }
        }

        private void MainWindow_OnClosed(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
        }

        private void MainWindow_EditorButton_OnClick(object sender, RoutedEventArgs e)
        {
            EditorWindow Editor = new EditorWindow();
            Editor.ShowDialog();
        }
    }
}
